import 'package:flutter/material.dart';

import '../resources.dart';

/// created by hcl
/// on 2023/3/6
/// page base_model
/// desc
enum StateEnum { loading, success, empty, error }

abstract class BaseModel with ChangeNotifier {
  bool _disposed = false;
  StateEnum state = StateEnum.success;
  late BuildContext mContext;

  void initData();

  void showToast(String msg) {
    Toast.showToast(mContext, msg);
  }

  @override
  void notifyListeners() {
    if (!_disposed) {
      super.notifyListeners();
    }
  }

  @override
  @mustCallSuper
  void dispose() {
    _disposed = true;
    super.dispose();
  }
}
